package com.linoer.cloud.alo.orderservice.service.imp;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linoer.cloud.alo.common.domain.ObjectResponse;
import com.linoer.cloud.alo.common.domain.dto.OrderDTO;
import com.linoer.cloud.alo.common.domain.enums.ResponseStatus;
import com.linoer.cloud.alo.orderservice.domain.Order;
import com.linoer.cloud.alo.orderservice.mapper.OrderMapper;
import com.linoer.cloud.alo.orderservice.service.OrderService;
import org.springframework.stereotype.Service;

/**
 * @Classname OrderServiceImp
 * @Description TODO
 * @Date 2021/6/22 4:39 下午
 * @Created by muhenglv
 */
@Service
public class OrderServiceImp extends ServiceImpl<OrderMapper, Order> implements OrderService {

    @Override
    public ObjectResponse createOrder(OrderDTO order) {
        ObjectResponse response = new ObjectResponse<>();
        int result = this.baseMapper.createOrder(order.getCommodityCode(), order.getCount(), order.getUserId(), order.getMoney());
        if (result < 0){
            response.setStatus(ResponseStatus.FAIL.getCode());
            response.setMessage(ResponseStatus.FAIL.getMessage());
        }else {
            response.setStatus(ResponseStatus.SUCCESS.getCode());
            response.setMessage(ResponseStatus.SUCCESS.getMessage());
        }
        return response;
    }
}
